package com.haiyou.dc.netty.chat;

import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;

import java.util.*;

@Slf4j
public class ClientsMap {

    private static Map<String, Channel> channelMap = new HashMap<>();

    public static void put(String senderId, Channel channel) {
        channelMap.put(senderId, channel);
    }

    public static Channel get(String senderId) {
        return channelMap.get(senderId);
    }

    public static Boolean containsKey(String senderId) {
        return channelMap.containsKey(senderId);
    }

    public static List<String> print() {
        Set<Map.Entry<String, Channel>> entries = channelMap.entrySet();
        List<String> strings = new ArrayList<>();
        for (Map.Entry entry : entries) {
            strings.add(entry.getKey().toString());
        }
        return strings;

    }
}
